#include "process.h"

typedef void (*ptr)(double,double);
double speed[6] = {1.0,10,0.3,0.2,4,0.1};

void upload(double total,ptr p)
{
    double current = 0.0;
    srand(time(NULL));
    while(current <= total)
    {
        p(total,current);
        if(current == total)
        {
            break;
        }
        int random=rand()%6;
        current += speed[random];
        if(current >= total)
        {
            current = total;
        }
        usleep(10000);
    }
    printf("\n");
}

void download(double total,ptr p)
{
    double current = 0.0;
    srand(time(NULL));
    while(current <= total)
    {
        p(total,current);
        if(current == total)
        {
            break;
        }
        int random = rand()%6;
        current += speed[random];
        if(current >= total)
        {
            current = total;
        }
        usleep(10000);
    }
    printf("\n");
}


int main()
{
    download(1024.0,Flushprocess);
    return 0; 
}

